package com.kern.academic.repository;

import com.kern.academic.entity.XMenu;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by caoshi at 7:22 2021-07-01
 */
public interface IMenuRepository extends JpaSpecificationExecutor<XMenu>, JpaRepository<XMenu, String> {

    /**
     * 查询所有一级菜单项
     * @return
     */
    @Query("select m from XMenu m where m.pid = ''")
    List<XMenu> findRootMenus();


    /**
     * 根据pid查询菜单项
     * @param pid
     * @return
     */
    List<XMenu> findByPid(String pid);

}
